<?php
	require  '../db.func.php';
	require  '../tools.func.php';
	require  'auth.php';
	require 'head.php';

	date_default_timezone_set("PRC");
	if(!empty($_POST['username'])){
		$u=$_POST['username'];
		$pass=htmlentities($_POST['pass']);
		$okpass=htmlentities($_POST['okpass']);
		$name=htmlentities($_POST['name']);
		$phone=htmlentities($_POST['phone']);
		$email=htmlentities($_POST['email']);
		$age=htmlentities($_POST['age']);
		$prefix=getprefix();
		$c=date('Y-m-d H:i:s');
		
		if($pass==$okpass){
				$sql="INSERT INTO {$prefix}user(username,password,name,age,email,phone,created_at) VALUES('$u','$pass','$name','$age','$email','$phone','$c') ";
				execute($sql);
				setinfo('添加成功');


		}
		else{
			setinfo('两次密码不正确');
		}
	}
?>
				<div class="row">
					<div class="col-md-12">
						<div class="card">
							<div class="card-header card-header-primary">
								<h4 class="card-title">添加用户</h4>
								<p class="card-category">添加一个用户</p>
							</div>
							<div class="card-body">
								<p><?php if(hasinfo())  echo getinfo();?> </p>
								<form action="user_add.php" method="post">
									<div class="row">
										<div class="col-md-4">
											<div class="form-group">
												<label class="bmd-label-floating">用户名</label>
												<input type="text" class="form-control" name="username">
											</div>
										</div>
										<div class="col-md-4">
											<div class="form-group">
												<label class="bmd-label-floating">密码</label>
												<input type="password" class="form-control" name="pass">
											</div>
										</div>
										<div class="col-md-4">
											<div class="form-group">
												<label class="bmd-label-floating">确认密码</label>
												<input type="password" class="form-control" name="okpass">
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="bmd-label-floating">姓名</label>
												<input type="text" class="form-control" name="name">
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="bmd-label-floating">年龄</label>
												<input type="number" class="form-control" name="age">
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-12">
											<div class="form-group">
												<label class="bmd-label-floating">联系电话</label>
												<input type="text" class="form-control" name="phone">
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-12">
											<div class="form-group">
												<label class="bmd-label-floating">电子邮箱</label>
												<input type="email" name="email" class="form-control" name="email">
											</div>
										</div>
									</div>
									<button type="submit" class="btn btn-primary pull-right">添加用户</button>
									<div class="clearfix"></div>
								</form>
							</div>
						</div>
					</div>

				</div>
<?php 
	require 'foot.php';

?>